
/**
 * Please modify this class to meet your needs
 * This class is not complete
 */

package cz.proks.bank.service;

import java.io.IOException;

import javax.activation.DataHandler;
import javax.jws.WebService;
import javax.mail.util.ByteArrayDataSource;
import javax.xml.ws.soap.MTOM;

import cz.proks.bank.generator.Generator;
import cz.proks.bank.generator.PdfGenerator;
import cz.proks.bank.service.domain.ReportRequest;
import cz.proks.bank.service.domain.ReportRequest.AccountRecord;
import cz.proks.bank.service.exception.ReportException;

@MTOM
@WebService(endpointInterface = "cz.proks.bank.service.FileService", 
			serviceName = "FileService",
			portName = "FileServicePort",
			targetNamespace = "http://bank.proks.cz/service/FileService/")
public class FileServiceImpl implements FileService {
	
	public DataHandler generateAccountReport(String bankCode, Integer accountNumber, AccountRecord[] records) throws ReportException {				
		try {						
			Generator generator = new PdfGenerator();
			
			DataHandler dataHandler = generator.generate(bankCode, accountNumber, records);
			
			return dataHandler;
			
		} catch (Exception e) {
			throw new ReportException("Cannot generate report", e);
		}		
	}
}
